home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11436 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.3 KB  |  69 lines

  1. Path: uuneo.neosoft.com!usenet
  2. From: Wmatthew@lan-aces.com (W. Matthews)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Q: how to create an Object without creating the whole object
  5. Date: 14 Mar 1996 15:43:20 GMT
  6. Organization: LAN-ACES, Inc.
  7. Message-ID: <4i9eqo$dtu@uuneo.neosoft.com>
  8. References: <31454EC9.167E@imacsg2.epfl.ch>
  9. NNTP-Posting-Host: 198.65.178.8
  10. X-Newsreader: WinVN 0.92.5
  11.  
  12. In article <31454EC9.167E@imacsg2.epfl.ch>, Niels Hilbrink <niels@imacsg2.epfl.ch> says:
  13. >
  14. >Hi,
  15. >
  16. >Oke the problem is this (maybe it's in a FAQ but couldn't find the faq
  17. >so ...):
  18. >
  19. >Say you've got a class A which is composed of say 10 other class
  20. >(inheritance multiple and single whatever). But if I create an object
  21. >with new this class 'explodes' (all the member functions are created of
  22. >all the parentclasses) so you want the initialize only those parent
  23. >class you need say only class B.
  24. >
  25. >How do you do that ?
  26. >
  27. >something like:
  28. >        
  29. >        Aobj = (A*) new A::B()
  30. >
  31. >But this doen't work, can anybody tell me what will ?
  32. >
  33. >oh yeah this works of course :
  34. >        Bobj = new B;
  35. >
  36. >        Aobj = (A*) Bobj;
  37. >
  38. >but I don't want that, I don't want first to  have to create a B object
  39. >and "attach" it to the A object
  40. >
  41. >Gr.
  42. >Niels
  43. >
  44. >-- 
  45. >
  46. >   The most overlooked advantage to owning a computer is 
  47. >   that if they foul up there's no law against wacking   
  48. >   them around a little.                                 
  49. >
  50. >------------------------------------------------------------
  51. >Koen D'Hondt                                  Niels Hilbrink
  52. >koen@dutlhs1.lr.tudelft.nl      niels@dutlcc3.lr.tudelft.nl
  53. >
  54. >**** Ripley Software Development ****
  55. >(finger niels@dutlcc3.lr.tudelft.nl for more information.)
  56. >------------------------------------------------------------
  57. Have you tried using a generic base class?  Then, in class 'A'
  58. call the base with the appropriate class conversions to get 'B'.
  59. <Don't mind me, I may turn out to be rambling on this one.>
  60. ______________________________________________
  61. |Wyatt Matthews:       Tech Support Department |
  62. |WMATTHEW@LAN-ACES.COM        -Internet-       |
  63. |WMATTHEW.MHS@LAN-ACES          -MHS-          |
  64. |LAN-ACES Tech Support      (713)890-9786      |
  65. |LAN-ACES BBS               (713)890-9790      |
  66. |LAN-ACES Fax               (713)890-9731      |
  67. |LAN-ACES Sales             (713)890-9787      |
  68. ______________________________________________
  69.